//
//  StatusBottomView.swift
//  Weibo T
//
//  Created by mac on 15/12/1.
//  Copyright © 2015年 陈肖坤. All rights reserved.
//

import UIKit

class StatusBottomView: UIView {
    
    //MARK: 监听方法
    @objc private func retweetedBtnDidClick() {
        let temp = TempViewController()
       
        retweetedBtn.navController()?.pushViewController(temp, animated: true)
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置UI
    private func setupUI() {
        self.backgroundColor = UIColor.whiteColor()
        addSubview(retweetedBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)
        
        
        //布局
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
        }
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            //添加靠左约束
            make.right.equalTo(self.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(composeBtn.snp_width)

        }
        //分割线
        let sepView1 = sepView()
        addSubview(sepView1)
        let sepView2 = sepView()
        addSubview(sepView2)
        let sepView3 = sepView()
        addSubview(sepView3)
//        let sepView4 = sepView()
//        addSubview(sepView4)
        let Y = 0.3
        let W = 0.5
        let scale = 0.4
        //布局
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(W)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.width.equalTo(W)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        sepView3.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.height.equalTo(Y)
            make.left.right.equalTo(self)
        }
        //添加点击事件
        retweetedBtn.addTarget(self, action: "retweetedBtnDidClick", forControlEvents: .TouchUpInside)
    }
    private func sepView() -> UIView {
    
        let v = UIView()
        v.backgroundColor = UIColor(white: 0.90, alpha: 1.0)
        return v
    }
    
    //懒加载试图
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImage: nil, color: darkGraysColor, fontSize: 10, isNeedHighlighted: false, imageName: "timeline_icon_retweet")
   
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), fontSize: 10, isNeedHighlighted: false, imageName: "timeline_icon_comment")
    
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), fontSize: 10, isNeedHighlighted: false, imageName: "timeline_icon_unlike")
   }
